home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer (Italian) 35
/
PC Gamer IT CD 35 2-2.iso
/
STARDEMO
/
Starsiege_ATR2.exe
/
Starsiege
/
Missions.vol
/
SWARM_Mai_Lay_Dan.cs
< prev
next >
Wrap
Text File
|
1998-07-30
|
14KB
|
588 lines
//
// tagStdlib.cs
//
$snuffValue = 0;
$chokeValue = 0;
$sackValue = 0;
$winScore = 50;
$tagWon = 0;
$healTriggerReady = true;
$ammoTriggerReady = true;
//----------------------------------------------
function setDefaultMissionOptions()
{
$server::AllowTeamRed = true;
$server::AllowTeamBlue = false;
$server::AllowTeamYellow = true;
$server::AllowTeamPurple = false;
$server::TeamPlay = true;
$server::AllowDeathmatch = false;
$server::AllowTeamPlay = true;
}
function onMissionStart(%playerNum)
{
setKillValues();
displayKillValues();
//reinitialize scores of players who were in previous game
%count = playerManager::getPlayerCount();
for(%i = 0; %i < %count; %i = %i + 1)
{
%curPlayerNum = playerManager::getPlayerNum(%i);
initStats(%curPlayerNum);
}
//Make first person to enter sim IT
dataStore(0, strcat(%playerNum, "isIt"), "Yes");
wallDim(strcat(getName(%playerNum), " is now IT!"));
boundryCheck();
}
//-------------------------------------------------------------
function player::onAdd(%playerNum)
{
setKillValues();
displayKillValues();
initStats(%playerNum);
chat(%playerNum,0, strcat("Welcome to Starsiege SWARM, ", getName(%playerNum), ". Here are the rules: "));
chat(%playerNum,0, strcat("- You get " , $sackValue, " point(s) for SACKING 'IT'."));
chat(%playerNum,0, strcat("- You get ", $snuffValue, " points for SNUFFING someone while you are 'IT'."));
chat(%playerNum,0, strcat("- You CHOKE if 'IT' kills you and you lose ", $chokeValue, " point(s)."));
chat(%playerNum,0, "- You become 'IT' by sacking 'IT'.");
chat(%playerNum,0, strcat("- The first player to reach ", $winScore, " points wins the game."));
}
//-------------------------------------------------------------
function player::onRemove(%playerNum)
{
setKillValues();
displayKillValues();
if(%playerNum == getItNum())
{
%newItNum = getHighScorePlayerNum(%playerNum);
if(%newItNum != "" && %newItNum != 0)
{
dataStore(0, strcat(%newItNum, "isIt"), "Yes" );
wall(strcat(getName(%newItNum), " is now IT!"));
%vehicleId = playerManager::playerNumToVehicleId(%newItNum);
setTeam(%vehicleId, RED);
setVehicleSpecialIdentity(%vehicleId, true, RED);
resetAmmoTrigger(%newItNum);
resetHealTrigger(%newItNum);
}
}
cleanUp(%playerNum);
}
//-------------------------------------------------------------
function vehicle::onAdd(%vehicleId)
{
setTeam(%vehicleId, YELLOW);
//if no one is IT, make this person IT
if(getItNum() == false)
{
%playerNum = playerManager::vehicleIdToPlayerNum(%vehicleId);
dataStore(0, strcat(%playerNum, "isIt"), "Yes" );
wall(strcat(getName(%playerNum), " is now IT!"));
}
if(playerManager::vehicleIdToPlayerNum(%vehicleId) == getItNum())
{
setTeam(%vehicleId, RED);
setVehicleSpecialIdentity(%vehicleId, true, RED);
}
}
//----------------------------------------------
function vehicle::onDestroyed(%destroyedId, %destroyerId)
{
%destroyerNum = playerManager::vehicleIdToPlayerNum(%destroyerId);
%destroyedNum = playerManager::vehicleIdToPlayerNum(%destroyedId);
if($tagWon == 1)
{
return;
}
if(itKilledSelf(%destroyedNum, %destroyerNum))
{
return;
}
if(itKilledPlayer(%destroyedNum, %destroyerNum))
{
return;
}
if(playerKilledIt(%destroyedNum, %destroyerNum))
{
setTeam(%destroyerId, RED);
setVehicleSpecialIdentity(%destroyedId, false);
setVehicleSpecialIdentity(%destroyerId, true, RED);
return;
}
// if we got here, a not-it player must have killed another not-it player
// which is ignored
}
//--------------------------------------------------------
function itKilledSelf(%destroyedNum, %destroyerNum)
{
// if there is only one player, keep that player IT
if(playerManager::getPlayerCount() == 1)
{
return true;
}
if(%destroyerNum == getItNum() && %destroyedNum == getItNum())
{
%newItNum = getHighScorePlayerNum(%playerNum);
if(%newItNum != "" && %newItNum != 0)
{
dataStore(0, strcat(%destroyedNum, "isIt"), "No" );
dataStore(0, strcat(%newItNum, "isIt"), "Yes" );
wall(strcat(getName(%newItNum), " is now IT!"));
%vehicleId = playerManager::playerNumToVehicleId(%newItNum);
setTeam(%vehicleId, RED);
setVehicleSpecialIdentity(%vehicleId, true, RED);
resetAmmoTrigger(%newItNum);
resetHealTrigger(%newItNum);
}
return true;
}
return false;
}
//---------------------------------------------------------
function itKilledPlayer(%destroyedNum, %destroyerNum)
{
if(%destroyerNum == getItNum())
{
%snuffKey = strcat(%destroyerNum, "snuff");
%chokeKey = strcat(%destroyedNum, "choke");
dataStore(0, %snuffKey, 1 + dataRetrieve(0, %snuffKey));
dataStore(0, %chokeKey, 1 + dataRetrieve(0, %chokeKey));
if(playerWonGame(%destroyerNum))
{
return true;
}
else
{
wallDim(strcat(getName(%destroyedNum), " was Snuffed by IT!"));
%object = playerManager::playerNumToVehicleId(%destroyedNum);
chat(%object, 0, strcat(getName(%destroyedNum), " you CHOKED!"));
}
return true;
}
return false;
}
//-------------------------------------------------------
function playerKilledIt(%destroyedNum, %destroyerNum)
{
if(%destroyedNum == getItNum())
{
%newItKey = strcat(%destroyerNum, "isIt");
%oldItKey = strcat(%destroyedNum, "isIt");
%sackKey = strcat(%destroyerNum, "sack");
dataStore(0, %oldItKey, "No");
dataStore(0, %newItkey, "Yes");
dataStore(0, %sackKey, 1 + dataRetrieve(0, %sackKey));
if(playerWonGame(%destroyerNum))
{
return true;
}
else
{
wallDim(strcat(getName(%destroyerNum), " Sacked IT!"));
wall(strcat(getName(%destroyerNum), " is now IT!"));
}
resetAmmoTrigger(%destroyerNum);
resetHealTrigger(%destroyerNum);
return true;
}
return false;
}
//--------------------------------------------------------
function getItNum()
{
%count = playerManager::getPlayerCount();
for(%i = 0; %i < %count; %i = %i + 1)
{
%curPlayerNum = playerManager::getPlayerNum(%i);
if(dataRetrieve(0, strcat(%curPlayerNum, "isIt")) == "Yes")
{
return %curPlayerNum;
}
}
//return false if no one is IT
return false;
}
//--------------------------------------------------------
function getHighScorePlayerNum(%playerNum)
{
%highScore = 0;
%count = playerManager::getPlayerCount();
%highScorePlayerNum = "";
for(%i = 0; %i < %count; %i = %i + 1)
{
%curPlayerNum = playerManager::getPlayerNum(%i);
%score = getPlayerScore(%curPlayerNum);
if(%curPlayerNum != %playerNum && %score >= %highScore)
{
%highScore = %score;
%highScorePlayerNum = %curPlayerNum;
}
}
return %highScorePlayerNum;
}
//--------------------------------------------------------
function initStats(%playerNum)
{
dataStore(0, strcat(%playerNum, "snuff"), 0 );
dataStore(0, strcat(%playerNum, "choke"),0);
dataStore(0, strcat(%playerNum, "sack"),0);
dataStore(0, strcat(%playerNum, "isIt"),"No");
}
//-------------------------------------------------------
function playerWonGame(%playerNum)
{
if(getPlayerScore(%playerNum) >= $winScore)
{
$tagWon = 1;
wall("GAME OVER");
wall(strcat(getName(%playerNum), " won the Game!"));
%missionEnd = strcat(getName(%playerNum), " won the Game!");
messageBox(0, %missionEnd);
%orderFade = "fadeEvent(0, out, 5, 0,0,0 );";
schedule(%orderFade, 5.0);
schedule("missionEndConditionMet();", 10.0);
return true;
}
return false;
}
//--------------------------------------------------------
function cleanUp(%playerNum)
{
dataRelease(0, strcat(%playerNum, "snuff"));
dataRelease(0, strcat(%playerNum, "choke"));
dataRelease(0, strcat(%playerNum, "sack"));
dataRelease(0, strcat(%playerNum, "isIt"));
}
//--------------------------------------------------------
//--Score board stuff
function getPlayerScore(%a)
{
return (getPlayerSnuffs(%a) * $snuffValue + getPlayerSacks(%a) * $sackValue - getPlayerChokes(%a) * $chokeValue); // - getPlayerFriendlyKills(%a) * $friendlyKillValue);
}
function getPlayerSnuffs(%playerNum)
{
return dataRetrieve(0, strcat(%playerNum, "snuff"));
}
function getPlayerSacks(%playerNum)
{
return dataRetrieve(0, strcat(%playerNum, "sack"));
}
function getPlayerItStatus(%playerNum)
{
return dataRetrieve(0, strcat(%playerNum, "isIt"));
}
function getPlayerChokes(%playerNum)
{
return dataRetrieve(0, strcat(%playerNum, "choke"));
}
//----------------------------------------------
function initScoreboard()
{
deleteVariables("$ScoreBoard::PlayerColumn*");
deleteVariables("$ScoreBoard::TeamColumn*");
// Player ScoreBoard column headings
$ScoreBoard::PlayerColumnHeader1 = "SCORE";
$ScoreBoard::PlayerColumnHeader2 = "IT";
$ScoreBoard::PlayerColumnHeader3 = "SNUFFS";
$ScoreBoard::PlayerColumnHeader4 = "SACKS";
$ScoreBoard::PlayerColumnHeader5 = "CHOKES";
$ScoreBoard::PlayerColumnHeader5 = "PING";
//Player ScoreBoard column functions
$ScoreBoard::PlayerColumnFunction1 = "getPlayerScore";
$ScoreBoard::PlayerColumnFunction2 = "getPlayerItStatus";
$ScoreBoard::PlayerColumnFunction3 = "getPlayerSnuffs";
$ScoreBoard::PlayerColumnFunction4 = "getPlayerSacks";
$ScoreBoard::PlayerColumnFunction5 = "getPlayerChokes";
$ScoreBoard::PlayerColumnFunction5 = "getPing";
// tell server to process all the scoreboard definitions defined above
serverInitScoreBoard();
}
// ------TRIGGER OVERLOADS-------------
//--------------------------------------
function heal::trigger::onEnter(%this, %object)
{
%playerNum = playerManager::vehicleIdToPlayerNum(%object);
//playSound(%object, IDCV_POWER_ON);
chat(%object, 0, "Entering repair area.");
if(%playerNum == getItNum() && $healTriggerReady == true)
{
healObject(%object, 10000.0);
healObject(%object, 10000.0);
healObject(%object, 10000.0);
$healTriggerReady = false;
initResetHealTimer(%playerNum);
}
}
//--------------------------------------
function reload::trigger::onEnter(%this, %object)
{
%playerNum = playerManager::vehicleIdToPlayerNum(%object);
//playSound(%object, IDCV_POWER_ON);
chat(%object, 0, "Entering reload area.");
if(%playerNum == getItNum() && $ammoTriggerReady == true)
{
reloadObject(%object, 100.0);
$ammoTriggerReady = false;
initResetAmmoTimer(%playerNum);
}
}
//---------------------------------------------
function initResetHealTimer(%playerNum)
{
%playerCount = playerManager::getPlayerCount();
%timer = 70 - ((%playerCount - 1) * 5);
if( %timer < 30)
{
%timer = 30;
}
%order = strcat("resetHealTrigger(", %playerNum, ");");
schedule (%order, %timer);
}
//-----------------------------------------------
function initResetAmmoTimer(%playerNum)
{
%playerCount = playerManager::getPlayerCount();
%timer = 70 - ((%playerCount - 1) * 5);
if( %timer < 30)
{
%timer = 30;
}
%order = strcat("resetAmmoTrigger(", %playerNum, ");");
schedule (%order, %timer);
}
//---------------------------------------------
function resetAmmoTrigger(%playerNum)
{
%object = playerManager::playerNumToVehicleId(%playerNum);
if (%playerNum == getItNum())
{
$ammoTriggerReady = true;
chat(%object, 0, "RELOAD PAD IS READY!");
}
}
//---------------------------------------------
function resetHealTrigger(%playerNum)
{
%object = playerManager::playerNumToVehicleId(%playerNum);
if (%playerNum == getItNum())
{
$healTriggerReady = true;
chat(%object, 0, "HEAL PAD IS READY!");
}
}
//--------------------------------------
function setKillValues()
{
%playerCount = playerManager::getPlayerCount();
if(%playerCount <= 2)
{
$snuffValue = 2;
$sackValue = 1;
$chokeValue = 0;
return;
}
if(%playerCount == 3)
{
$snuffValue = 3;
$sackValue = 1;
$chokeValue = 0;
return;
}
if(%playerCount == 4)
{
$snuffValue = 4;
$sackValue = 2;
$chokeValue = 1;
return;
}
if(%playerCount == 5)
{
$snuffValue = 6;
$sackValue = 3;
$chokeValue = 2;
return;
}
if(%playerCount == 6)
{
$snuffValue = 8;
$sackValue = 4;
$chokeValue = 2;
return;
}
if(%playerCount >= 7)
{
$snuffValue = 10;
$sackValue = 4;
$chokeValue = 2;
return;
}
return;
}
//------------------------------------------------------
function displayKillValues()
{
wallDim(strcat("POINT UPDATE: SNUFF = ", $snuffValue, " | SACK = ", $sackValue, " | CHOKE = ", $chokeValue));
}
//---------------------------------------------------
function boundryCheck()
{
%itNum = getItNum();
%itName = getName(%itNum);
%itVehicle = playerManager::playerNumToVehicleId(%itNum);
%distance = getDistance("MissionGroup/CenterPoint", %itVehicle);
if ( %distance >= 2000.0 )
{
wallDim(strcat(%itName, " has run away!"));
wallDim(strcat("Say goodbye to your score ", %itName, "!"));
// remove sacks and snuffs but keep chokes
%snuffKey = strcat(%itNum, "snuff");
%itKey = strcat(%itNum, "isIt");
%sackKey = strcat(%itNum, "sack");
dataStore(0, %snuffKey, 0);
dataStore(0, %itKey, "No");
dataStore(0, %sackKey, 0);
// select new It
%newItNum = getHighScorePlayerNum(%playerNum);
if(%newItNum != "" && %newItNum != 0)
{
dataStore(0, strcat(%newItNum, "isIt"), "Yes" );
wall(strcat(getName(%newItNum), " is now IT!"));
}
}
%order = "boundryCheck();";
schedule(%order, 10.0);
}